package leetcode;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-02-06 00:14
 **/
public class LeetCode1748 {

    public int sumOfUnique(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        int res = 0;
        for (int num : nums) {
            if (!map.containsKey(num)) {
                res += num;
                map.put(num, 1);
            } else if (map.get(num) == 1) {
                res -= num;
                map.put(num, 2);
            }
        }
        return  res;
    }

}
